﻿<!DOCTYPE HTML>
<html lang="zh-CN">
<head>
    <!--作为公共模版分离出去-->
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="admin/images/rookieCs.ico" />
    <link rel="Shortcut Icon" href="admin/images/rookieCs.ico" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui/css/H-ui.my.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/css/h-ui.admin.pro.iframe.min.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/Hui-iconfont/1.0.9/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/static/h-ui.admin.pro.iframe/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/default/easyui.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/jquery-easyui/1.7.0/themes/icon.css" />
    <link rel="stylesheet" type="text/css" href="admin/lib/lc_switch/20160127/css/lc_switch.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/iconfont/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="admin/css/mywork.css" />
    <script type="text/javascript" src="admin/lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="admin/lib/layer/3.1.1/layer.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/plugins/datagrid-detailview.js"></script>
    <script type="text/javascript" src="admin/lib/jquery-easyui/1.7.0/locale/easyui-lang-zh_CN.js"></script>
    <script type="text/javascript" src="admin/lib/lc_switch/20160127/js/lc_switch.min.js"></script>
    <script>document.write('<script type="text/javascript" src="admin/js/common.js?v='+ Date.now() +'"><\/script>');</script>
    <script>document.write('<script type="text/javascript" src="admin/js/formatter.js?v='+ Date.now() +'"><\/script>');</script>
    <!--作为公共模版分离出去-->
    <script type="text/javascript" src="admin/lib/echarts/4.8.0/echarts.min.js"></script>
    <title>新增公众号排期</title>
</head>
<body class="easyui-layout" style="width: 100%; height: 100%;font-family: 微软雅黑,serif" memuId="medium-list">
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en" style="float: none">&gt;</span> 排期管理
    <span class="c-gray en" style="float: none">&gt;</span> 新增公众号排期
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div data-options="region:'center', border:false">
    <!--按钮元素-->
    <div id="buttonInfo" style="padding: 2px 0px 2px 5px; background-color: #F5FAFE;">
        <button class="easyui-linkbutton" onclick="query(pageParam, true)"><i class="Hui-iconfont">&#xe665;</i>查询</button>
        <button class="easyui-linkbutton" onclick="addOrder()"><i class="Hui-iconfont">&#xe600;</i>新增排期</button>
    </div>
    <!--表格元素-->
    <div id="tableInfo"></div>
</div>
<div data-options="region:'east', title:'查询条件', hideCollapsedContent:false, collapsible:true, collapsed:true" style="width:250px">
    <!--查询条件元素-->
    <form id="searchFormInfo" style="display: none">
        <div class="searchLabel">对接媒介：<input id="s_mediumUserId" name="mediumUserId"/></div>
        <div class="searchLabel">公众号类别：<input id="s_label" name="label"/></div>
        <div class="searchLabel">公众号名称：<input id="s_name" name="name"/></div>
        <div class="searchLabel">微信号：<input id="s_weChatNo" name="weChatNo"/></div>
        <div class="searchLabel"><input id="s_numberType" name="numberType" /><input id="s_numberStart" name="numberStart" />-<input id="s_numberEnd" name="numberEnd" /></div>
        <div class="searchLabel">公司主体：<input id="s_hostCompany" name="hostCompany"/></div>
    </form>
</div>
<script type="text/javascript">
    //准备函数
    $(function () {
        initSearchForm();
        initGrid();
        getGridHidden("tableInfo");
        query(pageParam);
    });

    //查询条件初始化
    function initSearchForm() {
        $("#s_mediumUserId").combobox({
            width: 160,
            panelHeight: "auto",
            valueField: "id",
            textField: "name",
            editable: true,
            url: "user/listUserByRoleCode?roleCode=ALL",
            method: "GET",
            loadFilter: function (data) {
                var temp = data.bizData;
                if (temp.length > 1) {
                    temp.unshift({"id": "ALL", "name":"全部"});
                }
                return temp;
            }
        });
        $("#s_label").combobox({
            width: 150,
            editable: true,
            valueField: 'labelName',
            textField: 'labelName',
            url: "medium/getMediumLabelList?type=1",
            method: "GET",
            loadFilter: function (data) {
                return data.bizData;
            }
        });
        $("#s_name").textbox({
            width: 150
        });
        $("#s_weChatNo").textbox({
            width: 174
        });
        $("#s_numberType").combobox({
            width: 220,
            panelHeight: "auto",
            valueField: "value",
            textField: "text",
            data: [{value:1, text:"粉丝数量(万)", selected:true}, {value:2, text:"男粉比例(%)"}, {value:3, text:"女粉比例(%)"}, {value:4, text:"头条执行价"}, {value:5, text:"次条执行价"}, {value:6, text:"三条执行价"}, {value:7, text:"尾条执行价"}, {value:8, text:"头条成本价"}, {value:9, text:"次条成本价"}, {value:10, text:"三条成本价"}, {value:11, text:"尾条成本价"}]
        });
        $("#s_numberStart").numberbox({
            width: 108
        });
        $("#s_numberEnd").numberbox({
            width: 108
        });
        $("#s_hostCompany").textbox({
            width: 160
        });
        $("#searchFormInfo").show();
    }

    //表格元素初始化
    function initGrid() {
        $("#tableInfo").datagrid({
            pagination: true,
            singleSelect: true,
            fitColumns: false,
            striped: true,
            fit: true,
            frozenColumns: [[
                {field: "ck", checkbox: "true"},
                {field: "id", title: "编号", width: 60, align: "center", sortable: true},
                {field: "label", title: "公众号类别", width: 100, align: "center", sortable: true},
                {field: "name", title: "公众号名称", width: 120, align: "center", sortable: true, formatter: mediumNameFormatter},
                {field: "weChatNo", title: "微信号", width: 120, align: "center", sortable: true}
            ]],
            columns: [[
                {field: "fansSheets", title: "粉丝数量(万)", width: 100, align: "center", sortable: true},
                {field: "fansAge", title: "粉丝年龄段", width: 100, align: "center", sortable: true},
                {field: "manRatio", title: "<span style='color: #ab1e1e'>男</span>/<span style='color: #00CC00'>女</span>", width: 80, align: "center", sortable: true, formatter: mediumSexRatioFormatter},
                {field: "headLineQuoted", title: "头条执行价", width: 90, align: "center", sortable: true, formatter: mediumheadLineQuotedFormatter},
                {field: "secondLineQuoted", title: "次条执行价", width: 90, align: "center", sortable: true, formatter: mediumsecondLineQuotedFormatter},
                {field: "thirdLineQuoted", title: "三条执行价", width: 90, align: "center", sortable: true, formatter: mediumThirdLineQuotedFormatter},
                {field: "tailLineQuoted", title: "尾条执行价", width: 90, align: "center", sortable: true, formatter: mediumTailLineQuotedFormatter},
                {field: "headLineCost", title: "头条成本价", width: 90, align: "center", sortable: true, formatter: mediumHeadLineCostFormatter},
                {field: "secondLineCost", title: "次条成本价", width: 90, align: "center", sortable: true, formatter: mediumHeadLineCostFormatter},
                {field: "thirdLineCost", title: "三条成本价", width: 90, align: "center", sortable: true, formatter: mediumHeadLineCostFormatter},
                {field: "tailLineCost", title: "尾条成本价", width: 90, align: "center", sortable: true, formatter: mediumHeadLineCostFormatter},
                {field: "billPoint", title: "发票税点", width: 90, align: "center", sortable: true, formatter: mediumBillPointFormatter},
                {field: "hostCompany", title: "公司主体", width: 100, align: "center", sortable: true},
                {field: "voucherCount", title: "用户画像", width: 80, align: "center", formatter: mediumVoucherCountFormatter},
                {field: "refuseType", title: "拒接广告类型", width: 100, align: "center", sortable: true},
                {field: "brushType", title: "刷号类型", width: 80, align: "center", sortable: true},
                {field: "createUserName", title: "对接员工", width: 80, align: "center", sortable: true},
                {field: "updateDate", title: "更新时间", width: 130, align: "center", sortable: true, formatter: mediumUpdateDateFormatter},
                {field: "orderCount", title: "合作排期数", width: 80, align: "center", sortable: true},
                {field: "remark", title: "备注信息", width: 100, align: "center"}
            ]],
            toolbar: ".breadcrumb, #buttonInfo, #searchInfo",
            pageNumber: pageParam.pageNo,
            pageSize: pageParam.pageSize,
            pageList: Page.getPageList(),
            onSortColumn: function (orderBy, sortBy) {
                pageParam.pageNo = 1;
                pageParam.orderBy = orderBy;
                pageParam.sortBy = sortBy;
                query(pageParam);
            },
            onSelect: function() {
                selectedTableRow();
            },
            onUnselect: function() {
                selectedTableRow();
            },
            onSelectAll: function() {
                selectedTableRow();
            },
            onUnselectAll: function() {
                selectedTableRow();
            },
            onLoadSuccess: function() {
                toolBarBtnDisabledById([false, true], "buttonInfo");
            }
        }).datagrid("getPager").pagination({
            buttons: [
                {text: "个性化设置", iconCls: "icon-tip", handler: function() {selectColumnMenu("tableInfo");}}
            ],
            onSelectPage: function(pageNumber, pageSize) {
                pageParam.pageNo = pageNumber;
                pageParam.pageSize = pageSize;
                query(pageParam);
            },
            onChangePageSize: function(pageSize) {
                pageParam.pageSize = pageSize;
            }
        });
        //表格事件
        var selectedTableRow = function() {
            var selectRow = $("#tableInfo").datagrid("getSelections");
            if (selectRow.length === 0) {
                toolBarBtnDisabledById([false, true], "buttonInfo");
            } else if (selectRow.length === 1) {
                toolBarBtnDisabledById([false, false], "buttonInfo");
            } else {
                toolBarBtnDisabledById([false, true], "buttonInfo");
            }
        };
    }

    //分页查询
    function query(pageParam, goHead) {
        pageParam.condition = getFormJson($("#searchFormInfo"));
        pageParam.condition.type = 1;
        if (goHead && goHead)
            pageParam.pageNo = 1;
        ajaxGetFun("medium/queryMediumPage", pageParam, function(bizData) {
            $("#tableInfo").datagrid("loadData", bizData.rowList);
            $("#tableInfo").datagrid("getPager").pagination({pageNumber: bizData.pageNo, total: bizData.total});
        }, null, "获取公众号列表");
    }

    //新增
    function addOrder() {
        var selectRows = $("#tableInfo").datagrid("getSelections");
        if (selectRows.length !== 1) {
            return showWarnMsg("请选择公众号后操作");
        }
        openIframe(false, 500, 500, "order-info.html", function() {
            $("iframe")[0].contentWindow.$("#mediumId").val(selectRows[0].id);
            $("iframe")[0].contentWindow.$("#mediumPoint").combobox("setValue", selectRows[0].billPoint);
            $("iframe")[0].contentWindow.$("#putAddress").combobox("loadData", mediumPutAddressData);
        }, function(index, layero) {
            var formEle = layero.find("iframe")[0].contentWindow.$("#formInfo");
            if (formEle.form("validate")) {
                var orderInfo = getFormJson(formEle);
                //获取系统中已有的相似排期
                ajaxGetFun("order/listLikeOrder", orderInfo, function(bizData) {
                    if (bizData > 0) {
                        layer.confirm("已存在相似排期，继续创建可能会产生重复排期，是否继续？", function(index2) {
                            ajaxPostFun("order/saveOrderInfo", orderInfo, function() {
                                layer.close(index2);
                                layer.close(index);
                                query(pageParam, true);
                                showSuccessMsg("新增成功");
                            }, null, "新增排期");
                        });
                    } else {
                        ajaxPostFun("order/saveOrderInfo", orderInfo, function() {
                            layer.close(index);
                            query(pageParam, true);
                            showSuccessMsg("新增成功");
                        }, null, "新增排期");
                    }
                }, null, "获取系统中已有的相似排期");
            }
        });
    }
</script>
</body>
</html>